<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Config extends Model
{
    protected $guarded = [];
    /**
     * 获取配置值
     * @param $keys
     * @param array $default
     * @return array
     */
    public static function getValue($keys,$default = [])
    {
        $configs = self::query()->whereIn('key',$keys)->get();
        $values = [];
        foreach ($configs as $config){
            if(!$config->value){
                $config->value = $default[$config->key] ?? '';
            }
            $values[$config->key] = $config->value;
        }
        return $values;
    }

}
